import * as fs from 'fs';
import * as path from 'path';
import mysql from './mysql';
import MyCrypto from './MyCrypto'

export default {
    mysql,MyCrypto
}

export function pathResolve(_path):string{
    return path.resolve(_path);
}

export function  markPathSplit(pathName:string):string[]{
    return pathName.split(path.sep);
}

export function isExist(path:string):boolean{
    return fs.existsSync(path);
}

/**
 * example:
 * pathName: './test1/test2'
 * return : ['test1','test1/test2']
 * */
export function pathSplit(_path:string):string[]{
    _path = pathResolve(_path);
    let p:string[] = markPathSplit(_path);
    for(let i = 1,length = p.length;i < length;i++){
        p[i] = p[(i-1)] + path.sep + p[i]
    }
    return p;
}